ihelpuoo.xml.getElementText = function(ele,childName,defValue)
{
	var es = ele.getElementsByTagName(childName);
	if(null!=es && es.length>0)
		return ihelpuoo.xml.getText(es.item(0));
	if(defValue)
		return defValue;
	return null;
}

ihelpuoo.xml.getAttribute = function(ele,attName,defValue)
{
	var a = ele.getAttributeNode(attName);
	if(null!=a)
		return ihelpuoo.trim(a.value);
	if(defValue)
		return defValue;
	return null;
}

ihelpuoo.xml.getElementAsInteger = function(ele,childName,defValue)
{
	var s = ihelpuoo.xml.getElementText(ele,childName);
	return ihelpuoo.parseInt(s,defValue);
}

ihelpuoo.xml.getAttributeAsInteger = function(ele,attName,defValue)
{
	var s = ihelpuoo.xml.getAttribute(ele,attName);
	return ihelpuoo.parseInt(s,defValue);
}

ihelpuoo.xml.getElementAsBoolean = function(ele,childName,defValue)
{
	var s = ihelpuoo.xml.getElementText(ele,childName);
	return ihelpuoo.parseBoolean(s,defValue);
}

ihelpuoo.xml.getAttributeAsBoolean = function(ele,attName,defValue)
{
	var s = ihelpuoo.xml.getAttribute(ele,attName);
	return ihelpuoo.parseBoolean(s,defValue);
}

ihelpuoo.xml.getText = function(ele)
{
	if(!ele) return null;
	if(isIE)
		return ele.text;
	return ele.textContent;
}

ihelpuoo.xml.selectNodes=function(oRefNode,sXPath,oXmlNs){
	if(oRefNode==null){
		return null;
	}
	if(typeof XPathEvaluator!="undefined"){
		//ff's xpath engine
		oXmlNs=oXmlNs!=null?oXmlNs:{};
		var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};
		var oEvaluator=new XPathEvaluator();
		var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
		var aNodes=new Array();
		if(oResult!=null){
			var oElement=oResult.iterateNext();
			while(oElement){
				aNodes.push(oElement);
				oElement=oResult.iterateNext();
			}
		}
		return aNodes;
	}else if(document.all){
		if(oXmlNs){
			var sXmlNs="";
			for(var sProp in oXmlNs){
				sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";
			}
			oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);
		};
		return oRefNode.selectNodes(sXPath);
	}else{
		throw new Error("No XPath engine found.");
	}
};

/**
 * @method transformElement
 * transform the xml node to dom element
 * @param {Node} node
 * @return {Element} dom element
 */
ihelpuoo.xml.transformElement=function(node){
	var domElement = null;
	var tempNode = null;
	switch (node.nodeType){
		case Node.ELEMENT_NODE:
			var attributes = node.attributes;
			var name = null;
			var attribute = null;
			name = node.getAttribute("name");
			if(name != null && document.all){
				//create element include name for ie
				tempNode = document.createElement("<"+node.nodeName+" name=\""+name+"\"></"+node.nodeName+">");
			}else{
				tempNode = document.createElement(node.nodeName);
			}
			//begin to append the attributes
			ihelpuoo.xml.attachAttributeByList(tempNode,attributes);
			//script should append the text
			if(node.nodeName == "script" && node.childNodes.length>0)
			{
				tempNode.text = node.childNodes[0].nodeValue;
			}
			break;
		case Node.TEXT_NODE:
			if(!ihelpuoo.isBlank(node.nodeValue))
				tempNode = document.createTextNode(node.nodeValue);
			break;
		case Node.CDATA_SECTION_NODE:
			if(!ihelpuoo.isBlank(node.nodeValue))
				tempNode = document.createTextNode(node.nodeValue);
			break;
	}
	return tempNode;
};

ihelpuoo.xml.attachAttributeByList=function(tempNode,attributes)
{
	for(var i = 0; i < attributes.length; i++)
	{
		if(attributes[i].nodeName=="class")
		{
			tempNode.className = attributes[i].nodeValue;
		}
		else if(attributes[i].nodeName=="style")
		{
			tempNode.style.cssText = attributes[i].nodeValue;
		}
		else if(attributes[i].nodeName.indexOf("on")==0)
		{
			tempNode[attributes[i].nodeName]=new Function(attributes[i].value);
		}
		else if(tempNode.tagName=="INPUT" && attributes[i].nodeName=="autocomplete")
		{
			tempNode.autocomplete = attributes[i].nodeValue;
		}
		else
		{
			attribute = document.createAttribute(attributes[i].nodeName);
			attribute.value = attributes[i].value;
			attribute.nodeValue = attributes[i].nodeValue;
			tempNode.setAttributeNode(attribute);					
		}
	}
}

ihelpuoo.xml.isForError = function(doc)
{
	if(null==doc) return false;
	if(!doc.documentElement) return false;
	if(doc.documentElement.tagName!="ERROR-LIST") return false;
	return true;
}

